package com.hqd.ch03.v51.boot.context.properties.bind.handler;

import com.hqd.ch03.v51.boot.context.properties.bind.AbstractBindHandler;
import com.hqd.ch03.v51.boot.context.properties.bind.BindContext;
import com.hqd.ch03.v51.boot.context.properties.bind.BindHandler;
import com.hqd.ch03.v51.boot.context.properties.bind.Bindable;
import com.hqd.ch03.v51.boot.context.properties.source.ConfigurationPropertyName;

public class IgnoreErrorsBindHandler extends AbstractBindHandler {

    public IgnoreErrorsBindHandler() {
    }

    public IgnoreErrorsBindHandler(BindHandler parent) {
        super(parent);
    }

    @Override
    public Object onFailure(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Exception error)
            throws Exception {
        return (target.getValue() != null) ? target.getValue().get() : null;
    }

}
